<template>
  <div class="container">
    <div class="login-wrapper">
      <div class="header">Login</div>
      <div class="form-wrapper">
        <form action="/user/toLogin" id="form" method="post">
          <input
            type="text"
            v-model="username"
            name="username"
            placeholder="user"
            class="input-item"
          />
          <input
            type="password"
            v-model="password"
            name="password"
            placeholder="1234"
            class="input-item"
          />
          <div class="btn" @click="login">Login</div>
        </form>
      </div>
      <div class="msg">
        Don't have account?
        <a href="#">Sign up</a>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";

const router = useRouter();
const username = ref<string>("user");
const password = ref<string>("1234");

const login = () => {
  if (username.value === "user" && password.value === "1234") {
    router.push("/todolist_v2/index");
    return;
  }
  ElMessage({
    showClose: true,
    message: "账号或密码错误",
    type: "error",
  });
};

</script>

<style scoped>

.container {
  height: 100vh;
  background-image: linear-gradient(
    to right,
    #f87c07c5,
    rgb(238, 217, 148),
    #e98411
  );
}
.login-wrapper {
  background-color: rgba(255, 255, 255, 0.473);
  width: 358px;
  height: 588px;
  border-radius: 15px;
  padding: 0 50px;
  position: relative;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.header {
  font-size: 38px;
  font-weight: bold;
  text-align: center;
  line-height: 200px;
}
.input-item {
  background-color: transparent;
  display: block;
  width: 100%;
  margin-bottom: 20px;
  border: 0;
  padding: 10px;
  border-bottom: 1px solid rgb(128, 125, 125);
  font-size: 15px;
  outline: none;
}
.input-item:placeholder {
  text-transform: uppercase;
}
.btn {
  cursor: pointer;
  text-align: center;
  padding: 10px;
  width: 100%;
  margin-top: 40px;
  background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
  color: #fff;
}
.msg {
  text-align: center;
  line-height: 88px;
}
a {
  text-decoration-line: none;
  color: #abc1ee;
}
</style>
